#!/usr/bin/moon

require "lfs"

base_linux = "/home/linuxing3/workspace"
base_mac = "/Users/linuxing3/workspace"
newbase_linux = "/workspace"

dirs = {
	"java101",
	"lua101",
	"python101",
	"R101",
	"tex101",
	"java101",
	"wiki101",
}

printwd=->
	pwd = lfs.currentdir!
	print pwd

symlink=(s,t)->
	lfs.link(s,t,1)

delDir=(d)->
	print lfs.rmdir d


walkDir=(path)->
	for file in lfs.dir path
		if file!="." and file!=".."
			filepath = path.."/"..file
			attr = lfs.attributes filepath
			assert(type(attr)=="table")
			if attr.mode == "directory"	
				walkDir filepath 
			else
				print filepath
				for i,v in pairs attr
					print i,v

changeDir=()->
	for i in ipairs dirs
		source = base_linux.."/"..dirs[i] 
		target = newbase_linux.."/"..dirs[i] 
		lfs.rmdir target
		symlink source,target
		lfs.chdir target
		printwd! 

--Main function
--walkDir "." 
--lfs.mkdir newbase_linux
--delDir newbase_linux
changeDir!

--/usr/lib/luarocks/rocks-5.2/luafilesystem/1.6.2-1/doc/us/index.html
